package com.yz.app.sale.utils;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.engine.cache.DiskCache;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.load.engine.cache.ExternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.load.engine.cache.MemorySizeCalculator;
import com.bumptech.glide.module.GlideModule;

/**
 * ----------BigGod be here!----------/
 * ***┏┓******┏┓*********
 * *┏━┛┻━━━━━━┛┻━━┓*******
 * *┃             ┃*******
 * *┃     ━━━     ┃*******
 * *┃             ┃*******
 * *┃  ━┳┛   ┗┳━  ┃*******
 * *┃             ┃*******
 * *┃     ━┻━     ┃*******
 * *┃             ┃*******
 * *┗━━━┓     ┏━━━┛*******
 * *****┃     ┃神兽保佑*****
 * *****┃     ┃代码无BUG！***
 * *****┃     ┗━━━━━━━━┓*****
 * *****┃              ┣┓****
 * *****┃              ┏┛****
 * *****┗━┓┓┏━━━━┳┓┏━━━┛*****
 * *******┃┫┫****┃┫┫********
 * *******┗┻┛****┗┻┛*********
 * ━━━━━━神兽出没━━━━━━
 *
 * 项目名称：ProjectFunction
 * 类描述：
 * 创建人：zhangwei
 * 创建时间：2016-06-28 15:29
 * 修改人：zhangwei
 * 修改时间：2016-06-28 15:29
 * 修改备注：
 *
 * 如何配置缓存路径
 * 如何设置内存大小
 * 线程池大小
 *
 *
 */

public class CacheGlideModule implements GlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {

        MemorySizeCalculator calculator = new MemorySizeCalculator(context);
        int memoryCacheSize = calculator.getMemoryCacheSize();

        DiskLruCacheFactory factory = new ExternalCacheDiskCacheFactory(context, "image_cache", DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE);
        builder.setDiskCache(factory);


        LruResourceCache cache = new LruResourceCache((int) (1.2 * memoryCacheSize));
        builder.setMemoryCache(cache);


    }

    @Override
    public void registerComponents(Context context, Glide glide) {

    }
}
